﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AgentPartOrderList.aspx.cs" Inherits="IHISCETeim.Web.AgentSys.PWMgr.AgentPartOrderList" %>
<%--保外配件折扣申请--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="/MachineSys/EasyUI/themes/default/easyui.css"/>
	<link rel="stylesheet" type="text/css" href="/MachineSys/EasyUI/themes/icon.css" />
	<script type="text/javascript" src="/MachineSys/js/jquery-1.7.2.min.js"></script>   
	<script type="text/javascript" src="/MachineSys/EasyUI/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/MachineSys/EasyUI/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/MachineSys/EasyUI/easyui-formatter_20140718.js?v2"></script>
     <link href="/MachineSys/themes/css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
    <script src="/MachineSys/js/DWZ/jquery.autocomplete.js" type="text/javascript"></script>
    <script src="/MachineSys/js/DWZ/jquery.inputValue.js" type="text/javascript"></script>
    <script type="text/javascript">
        ///自适应宽高
        $(window).resize(function(){		    
            $("#tab_list").datagrid({
                width: '100%',
                height: $(parent.document).find(".tabsPageContent").height() - 11 > 0 ? $(parent.document).find(".tabsPageContent").height() - 11 : 500,
            }); 
        });

        $(document).ready(function () {
            //权限处理
            var $powers={
                "r查看":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.查看) %>,
                "r新增":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.新增) %>,
                "r修改":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.修改) %>,
                "r删除":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.删除) %>,
                "r导出":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.导出) %> 
                };
            //var $tab_toolbar=$("#tab_toolbar");
            //$tab_toolbar.find("a").each(function(){
            //    var $per=$(this).attr("Permission");
            //    var pt= $powers[$per]==undefined || null?true:$powers[$per];
            //    $(this).linkbutton(pt?'enable': 'disable');
            //})

            //自动完成
            $(".autocomplete").each(function () {
                var $this = $(this);
                var url = unescape($this.attr("autocompletehref"));
                $this.autocomplete(url);
            });
            //条件查询
            $("#search-buttons").find("#btn_search").click(function () {
                var query = $("#tab_search").serializeJSON(); // GetInputData("tab_search", "query");
                query.action = "query";
                $('#tab_list').datagrid("options").queryParams = query;
                $('#tab_list').datagrid('load');
                $("#tab_search").dialog("close");
                return false;
            });

            var lastIndex;
            $('#tab_list').datagrid({               
                url: location.href,
                queryParams: { "action": "query" },
                width: '100%', //宽度    
                height: $(parent.document).find(".tabsPageContent").height() - 11 > 0 ? $(parent.document).find(".tabsPageContent").height() - 11 : 500,
                toolbar: "#tab_toolbar",
                rowStyler:function(index,row)
                {
                    if(row.Status=="已发")
                        return  "color:red;";  
                }               
            });   
        })

        //修改，通过工具栏
        function onAddClick() {
         
            var rel = "AgentPartOrderEditADD";
            var url = "PWMgr/AgentPartOrderEdit.aspx?OrderId=0&action=add"
            var title = "添加订单";
            var options = { width: 850, height: 455, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
           // top.$.pdialog.open(url, rel, title, options);
             top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
            return false;
        }
        //修改，通过工具栏
        function onEditClick() {

            var row = $('#tab_list').datagrid('getSelected')
            if (row == null) {
                $.messager.alert('提示', '请先选择要修改的记录');
                return false;
            }           

            var OrderId = row.OrderId;
          //  var ID = row.ID;
            var rel = "AgentPartOrderEditUpdate";
            var url = "PWMgr/AgentPartOrderEdit.aspx?OrderId=" + OrderId+"&action=edit";
            var title = "审核订单";
            var options = { width: 850, height: 455, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
          //  top.$.pdialog.open(url, rel, title, options);
             top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
            return false;
        }
        //再确认，通过工具栏
        function onReCheckClick() {

            var row = $('#tab_list').datagrid('getSelected')
            if (row == null) {
                $.messager.alert('提示', '请先选择要再确认的记录');
                return false;
            }           
            if(row.OrderState!="再确认")
            {
                $.messager.alert('提示', '此订单无需再确认');
                return false;
            }
            var OrderId = row.OrderId;
            //  var ID = row.ID;
            var rel = "AgentPartOrderReCheck";
            var url = "PWMgr/AgentPartOrderEdit.aspx?OrderId=" + OrderId+"&action=add";
            var title = "再确认订单";
            var options = { width: 850, height: 455, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
            //  top.$.pdialog.open(url, rel, title, options);
            top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
            return false;
        }
        function onViewClick()
        {
            var row = $('#tab_list').datagrid('getSelected')
            if (row == null) {
                $.messager.alert('提示', '请先选择要查看的记录');
                return false;
            }           

            var OrderId = row.OrderId;
            var rel = "AgentPartOrderEditView";
            var url = "PWMgr/AgentPartOrderEdit.aspx?OrderId=" + OrderId+"&action=view";
            var title = "查看订单";
            var options = { width: 850, height: 455, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
            //  top.$.pdialog.open(url, rel, title, options);
            top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
            return false;
        }

        function onDeleteClick()
        {
            var row = $('#tab_list').datagrid('getSelected')
            if (row == null) {
                $.messager.alert('提示', '请先选择要删除的记录');
                return false;
            }           
            $('#tab_list').datagrid('unselectAll')//取消选中,不然会直接选中上次的数据
           
            $.messager.confirm('提示', '您确认要删除此订单记录吗？', function (r) {
                if (r) {
                    var OrderId = row.OrderId;
                    var url = "ajaxDone.ashx?ajaxmethod=deleteagentpartorder&OrderId=" + OrderId;
                    top.ajaxTodo(url, "");
                    $("#tab_list").datagrid("load");

                }
            });
        }

        function onExportClick() {
            var row = $('#tab_list').datagrid('getSelected')
            if (row == null) {
                $.messager.alert('提示', '请先选择要导出的记录');
                return false;
            }           

            var OrderId = row.OrderId;
            //var rel = "AgentPartOrderEditView";
            //var url = "PWMgr/AgentPartOrderEdit.aspx?OrderId=" + OrderId+"&action=view";
            //var title = "查看订单";
            //var options = { width: 850, height: 455, max: false, mask: true, maxable: false, minable: false, fresh: true, resizable: false, drawable: true };
            ////  top.$.pdialog.open(url, rel, title, options);
            //top.navTab.openTab(rel, url, { title: title, fresh: true, external: false });
            //return false;

            
            var href = "<%= ExportExcelWebUrl%>/AgentSys/AgentPWPartSing.aspx?id="+OrderId ;
           // alert(href)
            top.window.open(href, "");
        }
       
        function onExportPartClick()
        {
            var href = "<%= ExportExcelWebUrl%>/AgentSys/AgentPWPartList.aspx?" + jQuery.param($("#tab_search").serializeJSON());
            top.window.open(href, "");
            return false;
        }
    </script>
     
</head>
<body style="margin:2px;" >
     <div id="tab_search" title="查询条件" style=" height:250px; width:500px;" class="easyui-dialog" modal="true" closed="true" buttons="#search-buttons">
        <table class="table_search" width="100%" style=" line-height:21px;">
            <tr>
                <td width="80px">经销商:</td>
                <td width="120px">               
                    <input  name="AgentName"  />
                </td>
                <td width="80px">订单号:</td>
                <td width="80px"> <input  name="OrderNumber"  /></td>
            </tr>
            <tr>
                <td>机号:</td>
                 <td >               
                    <input  name="SerialNumber"  class="" />
                </td>
                 <td>用户:</td>
                 <td >               
                    <input  name="CustomerName"  class="" />
                </td>
            </tr>
            <tr>
                <td>发行日期:</td>
                 <td >               
                    <input  name="IssueDateForm"  class="easyui-datebox" />
                </td>
                 <td>到</td>
                 <td >               
                    <input  name="IssueDateTo"  class="easyui-datebox" />
                </td>
            </tr>
        </table>
        <div id="search-buttons" style=" ">
            <a id="btn_search" href="javascript:;" class="easyui-linkbutton" iconcls="icon-search" plain="true">提交</a> 
            <a href="javascript:;" class="easyui-linkbutton" onclick="$('#tab_search').dialog('close');return false;" iconcls="icon-cancel" plain="true">取消</a>
        </div>
    </div>

    <div id="tab_toolbar" style="padding:2px;">
       <a href="#" title="高级查找" class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="$('#tab_search').dialog('open');" Permission="">查找</a>
        <%if (HasPower(IHISCETeim.Web.Permission.新增)) {%> 
       <a href="#" title="添加订单" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="return　onAddClick();" Permission="r添加">添加订单</a>
        <a href="#" title="再确认订单" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="return　onReCheckClick();" Permission="r添加">再确认</a>
        <%} %>
        <%if (HasPower(IHISCETeim.Web.Permission.查看)) {%> 
        <a href="#" title="查看订单" class="easyui-linkbutton" iconcls="icon-ok" plain="true" onclick="return　onViewClick();" Permission="r查看">查看订单</a>
        <%} %>
          <%if (HasPower(IHISCETeim.Web.Permission.修改) ){%> 
        <a href="#" title="审核/取消订单" class="easyui-linkbutton" iconcls="icon-save" plain="true" onclick="return　onEditClick();" Permission="r修改">审核/取消订单</a>
       <%} %>
         <%if (HasPower(IHISCETeim.Web.Permission.删除)) {%> 
        <a href="#" title="删除订单" class="easyui-linkbutton" iconcls="icon-remove" plain="true" onclick="return　onDeleteClick();" Permission="r修改">删除订单</a>
       <%} %>
         <%if (HasPower(IHISCETeim.Web.Permission.导出)) {%> 
        <a href="#" title="删除订单" class="easyui-linkbutton" iconcls="icon-print" plain="true" onclick="return　onExportClick();" Permission="r导出">导出订单</a>
       <%} %>
          <%if (HasPower(IHISCETeim.Web.Permission.修改) ){%> 
        <a href="#" title="导出保外配件清单" class="easyui-linkbutton" iconcls="icon-save" plain="true" onclick="return　onExportPartClick();" Permission="r修改">导出保外配件清单</a>
       <%} %>
    </div>   

   <table id="tab_list" sortName="OrderId" sortOrder="DESC" iconCls="" singleSelect="true" idField="ID"  nowrap="false" striped="true" collapsible="false" remoteSort="true"  toolbar="#tab_toolbar"  pagination="true" pageNumber="1" pageSize="<%=numPerPage %>"  pageList="<%=SetnumPerPage() %>" rownumbers="true" showFooter="false" url="">
		<thead>
			<tr>
                 <th field="OrderState" width="80" sortable="true">订单状态</th>
                <th field="OrderNumber" width="100"  sortable="true">订单号</th>
				<th field="AgentName" width="100" sortable="true">经销商</th>
				<th field="IssueDate" width="100" formatter="formatterdate" sortable="true">发行日期</th>
                <th field="CustomerName" width="80" sortable="true">用户</th>
                <th field="SerialNumber" width="80" sortable="true">机号</th>
				<th field="MachineType" width="80" sortable="true">机型</th>
                <th field="CustomerMobile" width="100"  sortable="true">用户手机</th>
                <th field="IntoAddress" width="100"  sortable="true">工作地点</th>
                <th field="FaultDate" width="100"  sortable="true" formatter="formatterdate">故障日</th>
				<th field="WorkHour" width="80" sortable="true">工作小时</th>
                <th field="OrderTotal" width="80" sortable="true">订单总金额</th>
               
			</tr>
		</thead>
	</table>
</body>
</html>
